package git.soulbgm.handle;

import git.soulbgm.pojo.ProduceAlarmInfo;
import git.soulbgm.service.AlarmInfoService;
import git.soulbgm.thread.ProduceAlarmInfoThread;
import git.soulbgm.thread.ThreadTool;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import static git.soulbgm.common.MonitorConstants.TOPIC_PRODUCE_ALARM;

/**
 * 处理产生的告警信息
 *
 * @author 贺瑞杰
 * @date 2021-08-17
 */
@Component
@KafkaListener(topics = TOPIC_PRODUCE_ALARM)
public class ProduceAlarmInfoHandle {

    private final AlarmInfoService alarmInfoService;

    public ProduceAlarmInfoHandle(AlarmInfoService alarmInfoService) {
        this.alarmInfoService = alarmInfoService;
    }

    /**
     * 监听Kafka中topic的数据
     */
    @KafkaHandler
    public void listen(ProduceAlarmInfo info) {
        ThreadTool.IO_INTENSIVE_THREAD_POOL.execute(new ProduceAlarmInfoThread(info, alarmInfoService));
    }

}
